package cn.jingyuan.swan.system.web.controller;

import cn.jingyuan.swan.cloud.mapping.IgnoreApi;
import cn.jingyuan.swan.cloud.oauth2.DefaultUserDetails;
import cn.jingyuan.swan.cloud.oauth2.Principal;
import org.springframework.http.HttpEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;


@RestController
public class IndexController {

    @ResponseBody
    @GetMapping(path = "/")
    public HttpEntity index() {
        Map<String, Object> map = new HashMap<>();
        map.put("amt", 2.51D);
        map.put("size", 3.93F);
        map.put("pig", BigDecimal.valueOf(2.3D));

        // return map;

        return new HttpEntity(map);
        // return ResponseEntity.ok(map);

        // throw new SystemException(ExCode.ACCESS_AUTHORITY_EXPIRED);
    }

    @IgnoreApi
    @ResponseBody
    @GetMapping(path = "/say")
    public Object say(@Principal DefaultUserDetails userDetails) {
        Map<String, Object> map = new HashMap<>();
        map.put("amt", 2.51D);
        map.put("size", 3.93F);
        map.put("pig", BigDecimal.valueOf(2.3D));
        return map;
    }

}
